package com.ideafactory.client.ybservice.ybviewpager;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by LiuShao on 2016/5/24.
 */
public class GoodsDetialAdapter extends PagerAdapter {

    public List<GoodsBasePager> goodsBasePagers;

    public GoodsDetialAdapter(List<GoodsBasePager> goodsBasePagers){
        this.goodsBasePagers = goodsBasePagers;
    }

    @Override
    public int getCount() {
        return goodsBasePagers.size();
    }
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = goodsBasePagers.get(position).getRootView();
        container.addView(view, 0);
        return view;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }


}
